package com.nian.global.utils;

import java.lang.reflect.Field;

/**
 * Created by nian on 2022/10/22.
 */
public class EnumUtils {

    private EnumUtils() {
    }

    public static <T extends Enum<T>> void changeNameTo(T enumInstance, String value) {
        try {
            Field fieldName = enumInstance.getClass().getSuperclass().getDeclaredField("name");
            fieldName.setAccessible(true);
            fieldName.set(enumInstance, value);
            fieldName.setAccessible(false);
        } catch (Exception var3) {
        }

    }

    public static boolean enumEquals(Enum enum1, Enum enum2) {
        return enum1 == null && enum2 == null?true:(enum1 != null?enum1.equals(enum2):enum2.equals(enum1));
    }
}
